//
// Created by AssAs on 2024/9/23.
//

#ifndef AUDIO_WRAPPER_H
#define AUDIO_WRAPPER_H
#include <audio_recorder.h>


typedef enum {
    DUER_AUDIO_TYPE_UNKOWN,
    DUER_AUDIO_TYPE_SPEECH,
    DUER_AUDIO_TYPE_MUSIC,
} duer_audio_type_t;

typedef struct {
    const char *url;
    int offset;
    const char *audio_item_id;
} chat_audio_info_t;

enum _rec_msg_id {
    REC_START = 1,
    REC_STOP,
    REC_CANCEL,
};

typedef enum {
    PLAY_START,
    PLAY_INTERRUPT,
    PLAY_PLAYING,
    PLAY_STOP,
    PLAY_NONE,
} chat_audio_state_type_t;

#define PLAY_START_BIT     BIT0
#define PLAY_INTERRUPT_BIT BIT1
#define PLAY_PLAYING_BIT   BIT2
#define PLAY_STOP_BIT      BIT3

#ifdef __cplusplus
extern "C" {
#endif

    void audio_wrapper_init(void);
    void *chat_audio_setup_player(void);
    void *chat_audio_start_recorder(rec_event_cb_t cb);

    void chat_audio_wrapper_pause();
    int chat_audio_wrapper_get_state();
    void chat_listen_handler(void);
    void chat_stop_listen_handler(void);
    void chat_volume_set_handler(int volume);
    void chat_volume_adjust_handler(int volume);
    void chat_mute_handler(bool is_mute);
    void chat_get_speaker_state(int *volume, bool *is_mute);
    void chat_speak_handler(const char *url);
    void chat_audio_play_handler(const chat_audio_info_t *audio_info);
    void chat_audio_stop_handler();
    void chat_audio_pause_handler();
    void chat_audio_resume_handler(const chat_audio_info_t *audio_info);
    int chat_audio_get_play_progress();
    duer_audio_type_t chat_get_player_type();
    int chat_set_player_type(duer_audio_type_t num);
    int chat_audio_sync_play_tone(const char *uri);
    void chat_audio_play_tone(const char *url);
    void chat_audio_active_paused();
    void chat_audio_active_play();

    void chat_audio_stop_NOW();
    bool chat_audio_player_is_playing(void);
    void chat_audio_player_play(const char *url);
    void voice_2_psram(uint8_t *buffer, int len);
    void chat_vad_stop();
    void chat_vad_start();
    void chat_wwe_stop();
    void chat_wwe_start();

    void chat_shutup();
    void chat_audio_player_stop();
#ifdef __cplusplus
}
#endif


#endif //AUDIO_WRAPPER_H
